lib/checkout: Move special case for subpath of file to toplevel
authorColin Walters <walters@verbum.org>
Thu, 11 May 2017 01:43:26 +0000 (21:43 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 11 May 2017 14:15:54 +0000 (14:15 +0000)
Since we now have a cleaner separation of "toplevel checkout prep"
versus "recursive checkout", handle the special case of checking out
a single file at first rather than later.

Prep for future work in optimizing this function more.

Closes: #848
Approved by: jlebon

src/libostree/ostree-repo-checkout.c

index 50967769ca3972ee8c364bca6b3cf1f24ee2b472..9c1420ee20d762bbb6bb5a004fc8a8e3fd6cd4ce 100644 (file)
@@ -666,15 +666,6 @@ checkout_tree_at_recurse (OstreeRepo                        *self,
         return FALSE;
     }
 
-  /* Note early return here! */
-  if (g_file_info_get_file_type (source_info) != G_FILE_TYPE_DIRECTORY)
-    return checkout_one_file_at (self, options, state,
-                                 (GFile *) source,
-                                 source_info,
-                                 destination_dfd,
-                                 g_file_info_get_name (source_info),
-                                 cancellable, error);
-
   g_autoptr(GFileEnumerator) dir_enum =
     g_file_enumerate_children ((GFile*)source,
                                OSTREE_GIO_FAST_QUERYINFO,
@@ -789,6 +780,15 @@ checkout_tree_at (OstreeRepo                        *self,
       g_assert (options->force_copy);
     }
 
+  /* Special case handling for subpath of a non-directory */
+  if (g_file_info_get_file_type (source_info) != G_FILE_TYPE_DIRECTORY)
+    return checkout_one_file_at (self, options, &state,
+                                 (GFile *) source,
+                                 source_info,
+                                 destination_parent_fd,
+                                 g_file_info_get_name (source_info),
+                                 cancellable, error);
+
   /* Cache any directory metadata we read during this operation;
    * see commit b7afe91e21143d7abb0adde440683a52712aa246
    */